<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="rw.ac.kiosc.jdbc.school.School" %>
<%@page import="rw.ac.kiosc.jdbc.school.orm.User" %>
<%
        School school = new School();
        User user = null;
        if (session == null) {
            response.sendRedirect("login.htm");
        }
        String userIp = (String) session.getAttribute("userIp");
        int id = 0;
        String userId = (String) session.getAttribute("userId");
        if (userIp != null && userId != null) {
            try {
                id = Integer.parseInt(userId);
            } catch (Exception ex) {
                session.invalidate();
                response.sendRedirect("login.htm");
            }
            if (userIp.equals(request.getRemoteAddr())) {
                user = school.getUserDAO().getUserById(id);
                if (user == null) {
                    session.invalidate();
                    response.sendRedirect("login.htm");
                }
            } else {
                session.invalidate();
                response.sendRedirect("login.htm");
            }
        } else {
            session.invalidate();
            response.sendRedirect("login.htm");
        }
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>KIOSC</title>
    </head>
    <body>
        <%@include file="menu.jsp" %>
    </body>
</html>
